#pragma once

#include "Connection.h"
#include "../Common/Timer.h"


class ConnectionManager
	: private boost::noncopyable
{
public:
	ConnectionManager();

	/// Add the specified connection to the manager and start it.
	void start(ConnectionPtr c);

	ConnectionPtr findConnectionFromID(uint64 id);

	/// Stop the specified connection.
	void stop(ConnectionPtr c);

	/// Stop all connections.
	void stop_all();

	void update(uint32 timeElapse);

	typedef stdext::hash_map<uint64,ConnectionPtr> ConnectionMapType;
private:
	/// The managed connections.
	ConnectionMapType connections_;
	uint64 currentMaxID_;

	Timer eraseClosedConnectionTimer_;
};
